﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Service_monitoring.Utils.TimeTrick
{
    internal class TimeTrickHelper
    {
        public System.Windows.Forms.Timer timerGetTime;

        private void StartTimeTick(object sender, EventArgs e)
        {
            //创建定时器
            timerGetTime = new System.Windows.Forms.Timer();
            //设置定时器属性
            timerGetTime.Tick += new EventHandler(HandleTime);
            timerGetTime.Interval = 1000;
            timerGetTime.Enabled = true;
            //开启定时器
            timerGetTime.Start();
        }

        public void HandleTime(Object myObject, EventArgs myEventArgs)
        {
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            //   labelTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
    }
}